<template>
  <div class="item">
    <div class="pic" title="播放">
      <img :src="item.coverUrl" alt="" class="img" />
      <font-awesome-icon :icon="['far', 'circle-play']" class="play" />
    </div>
    <p class="name" @click="jump(router,item.id)" :title="item.name">{{ item.name }}</p>
    <span class="author" :title="item.dj.brand">{{ item.dj.brand }}</span>
    <span class="paly_num">播放{{ item.listenerCount }}</span>
    <span class="like_num">赞{{ item.likedCount }}</span>
    <span class="tag">
      <i class="a_tag">{{ item.radio.category }}</i>
    </span>
  </div>
</template>

<script setup>
import useJumpHook from "./Hooks/useJumpHook";
const router = useRouter();
const $props = defineProps({
  item: {
    type: Object,
    required: true,
  },
});
const { jump } = useJumpHook();
</script>

<style lang="scss" scoped>
.item {
  display: flex;
  align-items: center;
  padding-block: 6px;
  padding-inline: 15px;
  column-gap: 1.2%;
  max-height: 60px;
  height: 0.6rem;
  min-height: 40px;
  font-size: 12px;
  &:nth-child(even) {
    background-color: #f7f7f7;
  }
  &:hover {
    background-color: #eee;
    .pic {
      .play {
        display: block;
      }
    }
  }
  .pic {
    height: 100%;
    position: relative;
    cursor: pointer;
    .img {
      height: 100%;
    }
    .play {
      display: none;
      position: absolute;
      // 灵活控制一个字体图标的大小随屏幕宽度变化---
      font-size: 20px;
      width: 0.2rem;
      min-width: 15px;
      // 灵活控制一个字体图标的大小随屏幕宽度变化---
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      color: rgba(240, 240, 240);
      background-color: rgba(0, 0, 0, 0.4);
      border-radius: 50%;
    }
  }
  .name,
  .author,
  .paly_num,
  .like_num,
  .tag {
    flex-grow: 0;
    flex-shrink: 0;
    // 强制一行显示，剩余部分显示省略号：
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .name {
    width: 42%;
    cursor: pointer;
    &:hover {
      color: #000;
      text-decoration: underline;
    }
  }
  .author {
    width: 15%;
    color: #666;
    cursor: pointer;
    &:hover {
      text-decoration: underline;
    }
  }
  .paly_num,
  .like_num,
  .tag {
    color: #999;
  }
  .paly_num {
    width: 12%;
  }
  .like_num {
    width: 8%;
  }
  .tag {
    height: 30px;
    line-height: 30px;
    .a_tag {
      border: 1px solid #999;
      padding-inline: 5px;
      padding-block: 2px;
      line-height: 1;
      cursor: pointer;
      &:hover {
        color: #333;
        border-color: #333;
      }
    }
  }
}
</style>
